package com.mdh.runerrands.serviceImpl;

import com.mdh.runerrands.dao.AccountEmpDao;
import com.mdh.runerrands.dao.BaseUserDao;
import com.mdh.runerrands.pojo.AccountEmployee;
import com.mdh.runerrands.pojo.BaseUser;
import com.mdh.runerrands.service.AccountEmpService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class AccountEmpServiceImpl implements AccountEmpService {
    @Resource
    private AccountEmpDao accountEmpDao;

    @Resource
    private BaseUserDao baseUserDao;
    @Override
    public List<AccountEmployee> findById(int userId) {
        return accountEmpDao.selectByUserId(userId);
    }

    @Override
    public List<AccountEmployee> query(int page, int pageSize, String money, String type, String description) {
        page = (page-1)*pageSize;
        return accountEmpDao.selectQuery(page,pageSize,money,type,description);
    }

    @Override
    public int selectCount(String money, String type, String description) {
        return accountEmpDao.selectCount(money,type,description);
    }

    @Override
    public boolean updateWaiterCrash(int orderId, int waiterId) {
        BaseUser baseUser = baseUserDao.selectById(waiterId);
        int status = 0;
        String type = "提现";
        if (baseUser == null){
            return false;
        }
        String description = baseUser.getUsername()+"发起的提现申请";
        return accountEmpDao.updateWaiterCrash(orderId,waiterId,type,status,description);
    }

    @Override
    public boolean updateWaiterExamine(int orderId, int waiterId) {
        int status = 1;
        return accountEmpDao.updateWaiterExamine(orderId,waiterId,status);
    }

    @Override
    public boolean updateWaiterRefuseExamine(int orderId, int waiterId) {
        return accountEmpDao.updateWaiterRefuseExamine(orderId,waiterId);
    }
}
